package com.ldatum.crm.serviceImpl;

import java.util.List;

import com.ldatum.crm.dao.InventoryDao;
import com.ldatum.crm.dao.JhDao;
import com.ldatum.crm.daoImpl.InventoryDaoImpl;
import com.ldatum.crm.daoImpl.JhDaoImpl;
import com.ldatum.crm.domain.Jhdetail;
import com.ldatum.crm.service.JhdetailService;

public class JhdetailServiceImpl implements JhdetailService {
	JhDao jhDao = new JhDaoImpl();
	InventoryDao inventoryDao = new InventoryDaoImpl();

	@Override
	public int saveJhDetail(List<Jhdetail> jhDetailList) throws Exception {
		boolean b ;
		for(Jhdetail jd:jhDetailList){
			b = inventoryDao.validationNo(jd.getYpbm());
			if(b){
				inventoryDao.update(jd);
			}else{
				inventoryDao.save(jd);
			}
		}
		return jhDao.saveJhDetail(jhDetailList);
	}

	@Override
	public List<Jhdetail> findById(String no) throws Exception {
		return jhDao.findById(no);
	}

	@Override
	public List<Jhdetail> findByDjh(String djh) throws Exception {
		return jhDao.findByDjh(djh);
	}
	

}
